// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning;

public sealed partial class FilterRef
{
	/// <summary>
	/// <para>
	/// The identifier for the filter.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("filter_id")]
	public Elastic.Clients.Elasticsearch.Serverless.Id FilterId { get; set; }

	/// <summary>
	/// <para>
	/// If set to <c>include</c>, the rule applies for values in the filter. If set to <c>exclude</c>, the rule applies for values not in the filter.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("filter_type")]
	public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.FilterType? FilterType { get; set; }
}

public sealed partial class FilterRefDescriptor : SerializableDescriptor<FilterRefDescriptor>
{
	internal FilterRefDescriptor(Action<FilterRefDescriptor> configure) => configure.Invoke(this);

	public FilterRefDescriptor() : base()
	{
	}

	private Elastic.Clients.Elasticsearch.Serverless.Id FilterIdValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.MachineLearning.FilterType? FilterTypeValue { get; set; }

	/// <summary>
	/// <para>
	/// The identifier for the filter.
	/// </para>
	/// </summary>
	public FilterRefDescriptor FilterId(Elastic.Clients.Elasticsearch.Serverless.Id filterId)
	{
		FilterIdValue = filterId;
		return Self;
	}

	/// <summary>
	/// <para>
	/// If set to <c>include</c>, the rule applies for values in the filter. If set to <c>exclude</c>, the rule applies for values not in the filter.
	/// </para>
	/// </summary>
	public FilterRefDescriptor FilterType(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.FilterType? filterType)
	{
		FilterTypeValue = filterType;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		writer.WritePropertyName("filter_id");
		JsonSerializer.Serialize(writer, FilterIdValue, options);
		if (FilterTypeValue is not null)
		{
			writer.WritePropertyName("filter_type");
			JsonSerializer.Serialize(writer, FilterTypeValue, options);
		}

		writer.WriteEndObject();
	}
}